package main

import (
	"api/app/auth/auto/v1/mc"
	"api/app/auth/models"
	"api/app/auth/service"
	"api/config"
	"api/libs/orm"
	"gitee.com/dreamwood/ez"
)

func createUser() {
	db := config.GetDb()
	f := orm.NewFactory(mc.UserEzConfig)
	f.SetDb(db)

	admin := new(models.User)
	admin.Id = 1
	admin.Name = "超级管理员"
	admin.Age = 100
	admin.Account = "sa"
	admin.Birthday = "2021-03-01"
	admin.Code = "000000"
	admin.Phone = "18888888888"
	admin.Sex = 1

	admin.Salt = "ABC"
	admin.Password = service.GenPass("123123", admin.Salt)
	admin.Roles = []*models.Role{
		&models.Role{Id: 1},
	}

	e := f.Create(admin)
	ez.PrintError(e)
}

func createRole() {

	db := config.GetDb()
	role := new(models.Role)
	role.Id = 1
	role.Name = "超级管理员"
	role.Link = "sa"
	role.Key = "sa"
	role.Save(db)

}
